#include <stdio.h>
#include <stdint.h>
#include <unistd.h>

#include "fbmap.h"

#define WIDTH   100
#define HEIGHT  100

// 设置颜色
void set(uint8_t *map, uint32_t mapSize, uint32_t rgbColor)
{
    uint32_t offset;
    uint8_t r = (rgbColor >> 16) & 0xFF;
    uint8_t g = (rgbColor >> 8) & 0xFF;
    uint8_t b = (rgbColor >> 0) & 0xFF;
    for (offset = 0; offset < mapSize;)
    {
        map[offset++] = r;
        map[offset++] = g;
        map[offset++] = b;
    }
}

int main(void)
{
	uint8_t rgbMap[WIDTH * HEIGHT * 3];
	while(1)
	{
		set(rgbMap, sizeof(rgbMap), 0xFC0000);//红
		fb_output(rgbMap, 100, 100, WIDTH, HEIGHT);
		sleep(1);

		set(rgbMap, sizeof(rgbMap), 0x00FF00);//绿
		fb_output(rgbMap, 100, 100, WIDTH, HEIGHT);
		sleep(1);

		set(rgbMap, sizeof(rgbMap), 0x0000FF);//蓝
		fb_output(rgbMap, 100, 100, WIDTH, HEIGHT);
		sleep(1);
	}
    return 0;
}
